package com.chentianyu.learn.demo01.controller;

import com.chentianyu.learn.demo01.object.User;
import com.chentianyu.learn.demo01.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UsersController {
    @Autowired
    UsersService usersService;
    @GetMapping("/getUsers")
    public List<User> selectUser(){
        return usersService.selectUser();
    }
    @PostMapping("/insertUser")
    public String insertUser(@RequestParam("uid") Integer uid,@RequestParam("name") String name){
        usersService.insertUser(uid, name);
        return "OK";
    }
}
